{include_core file="lib/header.html" title="我的订单" center="center"}
{include_core file="lib/top_nav.html"}
<style>
  .info .info-box .info-table2 .info-table tr:last-child{
    border-bottom: none;
  }
</style>
<div class="container">
  <div class="inner">
    <div class="con-top clearfix">
      {include_core file="lib/sidebar.html" crumbs_1="center" crumbs_2="order"}
      <div class="details">
        <div>
          <div class="number">
            <span>订单号：</span>
            <span>{order_helper::order_id_encode($order_info.id)}</span>　　　
            <span>状态：</span>
            <span class="social">{order_config::$dealer_progress[$order_info.progress]}</span>
          </div>
          <div class="know">
            <div class="key">
              <ul class="clearfix">
                <li {if $order_info.progress == 0}style="line-height:36px"{/if}>
                  <h3><img src="{$smarty.const.SITE_URL}/images/arrow2.png"/></h3>
                  {if $order_info.progress != 0}
                  <div class="step undel"><a class="ico" href="javascript:void(0);"></a><span>下单</span></div>
                  <span>{date('Y-m-d', strtotime($order_info.add_time))}</span>
                  <span>{date('H:i:s', strtotime($order_info.add_time))}</span>
                  {else}
                  <div class="undel"><a href="javascript:void(0);">1</a><span>下单</span></div>
                  {/if}
                </li>
                <li {if $order_info.progress == 1}class="key-curr"{elseif $order_info.progress == 0}style="line-height:36px"{/if}>
                  {if $order_info.progress == 1}
                  <h3><img src="{$smarty.const.SITE_URL}/images/arrow.png"/></h3>
                  {else}
                  <h3><img src="{$smarty.const.SITE_URL}/images/arrow2.png"/></h3>
                  {/if}
                  {if $order_info.progress > 1}
                  <div class="step undel"><a class="ico" href="javascript:void(0);"></a><span>支付</span></div>
                  <span>{substr($order_info.pay_time, 0, 10)}</span>
                  <span>{date('H:i:s', strtotime($order_info.pay_time))}</span>
                  {else}
                  <div class="undel"><a href="javascript:void(0);">2</a><span>支付</span></div>
                  {/if}
                {if $order_info.progress == 1}<span>请在24小时以内付款</span>{/if}
                </li>
                <li {if $order_info.progress == 10}class="key-curr"{/if}>
                  {if $order_info.progress == 10}
                  <h3><img src="{$smarty.const.SITE_URL}/images/arrow.png"/></h3>
                  {else}
                  <h3><img src="{$smarty.const.SITE_URL}/images/arrow2.png"/></h3>
                  {/if}
                  {if $order_info.progress > 10}
                  <div class="step undel"><a class="ico" href="javascript:void(0);"></a><span>配货</span></div>
                  <span>{substr($order_info.pay_time, 0, 10)}</span>
                  <span>{date('H:i:s', strtotime($order_info.pay_time)+650)}</span>
                  {else}
                  <div class="undel"><a href="javascript:void(0);">3</a><span>配货</span></div>
                  {/if}
                </li>
                <li {if $order_info.progress == 15}class="key-curr"{/if}>
                  {if $order_info.progress == 15}
                  <h3><img src="{$smarty.const.SITE_URL}/images/arrow.png"/></h3>
                  {else}
                  <h3><img src="{$smarty.const.SITE_URL}/images/arrow2.png"/></h3>
                  {/if}
                  {if $order_info.progress > 15}
                  <div class="step undel"><a class="ico" href="javascript:void(0);"></a><span>出库</span></div>
                  <span>{substr($order_info.deliver_time, 0, 10)}</span>
                  <span>{date('H:i:s', strtotime($order_info.deliver_time))}</span>
                  {else}
                  <div class="undel"><a href="javascript:void(0);">4</a><span>出库</span></div>
                  {/if}
                </li>
                <li class="last-li {if $order_info.progress == 20}key-curr{/if}">
                  <div class="undel"><a href="javascript:void(0);">5</a><span>交易成功</span></div>
                </li>
              </ul>
            </div>
            <div class="key2">
              <div><span>{date('Y-m-d', strtotime($order_info.add_time))}</span><span>{date('H:i:s', strtotime($order_info.add_time)-10)}</span><span>订单已提交，请等待系统确认</span></div>
              <div class="nota"><span>{date('Y-m-d', strtotime($order_info.add_time))}</span><span>{date('H:i:s', strtotime($order_info.add_time))}</span>{if $order_info.progress == 1}<a href="javascript:void(0);">订单确认，等待付款{else}<span>订单确认，等待付款</span></a>{/if}</div>
              {if $order_info.progress >= 10}
              <div class="nota"><span>{substr($order_info.pay_time, 0 ,10)}</span><span>{date('H:i:s', strtotime($order_info.pay_time))}</span>{if $order_info.progress == 10}<a href="javascript:void(0);">已付款，等待发货</a>{else}<span>已付款，等待发货</span>{/if}</div>
              {/if}
              {if $order_info.progress >= 15}
              <div class="nota js_expressInfo" data-order_id="{$order_info.id}"><span>{substr($order_info.deliver_time, 0, 10)}</span><span>{date('H:i:s', strtotime($order_info.deliver_time))}</span>{if $order_info.progress == 15}<a href="javascript:void(0);">已发货。物流公司：{_uri('express', $order_info.express_id, 'title')}　运单号码：{$order_info.express_no}</a>{else}<span>已发货。物流公司：{_uri('express', $order_info.express_id, 'title')}　运单号码：{$order_info.express_no}</span>{/if}</div>
              {/if}
              {if $order_info.progress >= 20}
              <div class="nota"><span>{substr($order_info.receiver_time, 0, 10)}</span><span>{date('H:i:s', strtotime($order_info.receiver_time))}</span>{if $order_info.progress == 20}<a href="javascript:void(0);">已收货</a>{else}<span>已收货</span>{/if}</div>
              {/if}
              {if $order_info.progress == 0}
              <div class="nota"><span>{substr($order_info.update_time, 0, 10)}</span><span>{date('H:i:s', strtotime($order_info.update_time))}</span><span>取消订单</span></div>
              {/if}
              {$refund_info = service_helper::get_refund_status($order_info.id)}
              {if $refund_info && $order_info.progress == 0}
                <div class="nota"><span>{substr($refund_info.refund_time, 0, 10)}</span><span>{date('H:i:s', strtotime($refund_info.refund_time))}</span><span>提交退款</span></div>
                {if $refund_info.status >= 1}
                <div class="nota"><span>{substr($refund_info.refund_time, 0, 10)}</span><span>{date('H:i:s', strtotime($refund_info.refund_time))}</span><span>退款处理中</span></div>
                {/if}
                {if $refund_info.status == 2}
                <div class="nota"><span>{substr($refund_info.refund_time, 0, 10)}</span><span>{date('H:i:s', strtotime($refund_info.refund_time))}</span><a href="javascript:void(0);">退款完成</a></div>
                {/if}
              {/if}
            </div>
          </div>
        </div>

        <div class="info">
          <h4>商品信息</h4>
          <div class="info-box clearfix">
            <table class="info-table2">
              <tr>
                <th>商品详情</th>
                <th>单价</th>
                <th>数量</th>
                {if $order_info.progress >= 1 && $order_info.progress <= 10}
                <th>操作</th>
                {/if}
              </tr>
              <tr>
                <td colspan="3">
                  <table class="info-table">
                    {$goods_total = 0}
                    {$count_num = count($order_detail)}
                    {foreach $order_detail as $k=>$v}
                    {$goods_total =  $goods_total + $v.goods_num*$v.goods_price}
                    <tr {if $count_num-1 == $k}class="last-tr"{/if}>
                      <td class="info-width">
                        <dl class="clearfix js_openLink" data-target="_blank" data-href="{AnUrl("goods/{$v.goods_id}")}">
                          <dt><img src="{_image($v.goods_cover)}" width="100"/></dt>
                          <dd>
                            <div>{$v.goods_title} {if $v.is_gift == 1} <span class="center-gift">赠品</span>{/if}{if $v.is_promotion == 1} <span class="center-promotion-gift">加价购</span>{/if}</div>
                            <div>{goods_helper::get_sku_property_value($v.sku_id)}</div>
                          </dd>
                        </dl>
                      </td>
                      <td class="colot info-width2">{number_format($v.goods_price, 2)}元</td>
                      <td class="info-width3">{$v.goods_num}</td>
                    </tr>
                    {/foreach}
                  </table>
                </td>
                {if $order_info.progress >= 1 && $order_info.progress <= 10}
                <td class="info-left mouse-pointer js_cancelOrder" data-order_id="{$order_info.id}">取消订单></td>
                {/if}
              </tr>
            </table>
            <div class="pay clearfix">
              <ul>
                <li><span>商品总价：</span><a href="javascript:void(0);">{number_format($goods_total, 2)}元</a></li>
                <li><span>优惠金额：</span><a href="javascript:void(0);">{if $order_info.promotion_price}-{number_format($order_info.promotion_price, 2)}{else}0.00{/if}元</a></li>
                <li><span>运　　费：</span><a href="javascript:void(0);" class="js_orderExpressPrice">{number_format($order_info.post_price, 2)}元</a></li>
                <li>
                  <span>实付金额：</span>
                  <div class="money"><em class="js_orderTotalPrice">{number_format($order_info.price, 2)}</em>元</div>
                </li>
              </ul>
              {if $order_info.progress == 1}
              <div class="once">{if $end_time}<span class="js_orderTime" data-hour="{$hour}" data-min="{$min}">{$hour}小时{$min}分钟后</span>　<em>订单将被关闭</em> <a href="javascript:void(0);" class="js_openLink js_subOrder" data-login="1" data-target="_blank" data-href="{order_helper::get_order_pay_url($order_info.id)}" >立即支付</a>{else}订单被关闭{/if}</div>
              {/if}
            </div>
          </div>
        </div>
        <!--info end-->

        <div class="address">
          <h4>收货信息</h4>
          <div class="address-box js_addressInfo" data-address_id="">
            <div class="ress"><span>收货地址</span>{if $order_info.progress == 1}<a href="javascript:void(0);" class="js_modifyAddress">[修改]</a>{/if}</div>
            <ul>
              <li><span>姓　　名 :</span><span class="address-txt name">{$order_info.receiver}</span></li>
              <li><span>收货地址 :</span><span class="address-txt address">{$order_info.province} {$order_info.city} {$order_info.district}</span><span class="address-detail">{$order_info.address}</span></li>
              <li><span>联系方式 :</span><span class="address-txt tel">{$order_info.mobile}</span></li>
            </ul>
            <div class="ress"><span>发票信息</span></div>
            <ul>
              {*<li><span>发票类型 :</span><span class="address-txt">普通发票</span></li>*}
              {if $order_info.invoice_type}
              <li><span>发票类型 :</span><span class="address-txt">{order_config::$invoice_type[$order_info.invoice_type]}{if $order_info.invoice_type == 1 && order_helper::get_order_refund_url($order_info['id'])}<a href="{order_helper::get_order_refund_url($order_info['id'])}" style="color:#0000ff">（下载电子发票）</a>{/if}</span></li>
              <li><span>发票内容 :</span><span class="address-txt">{$order_info.invoice_title}</span></li>
              {/if}
            </ul>

            <div class="line js_payTypeInfo">
              <div class="ress"><span>支付及配送方式</span>{if $order_info.progress == 1}<a href="javascript:void(0);" class="js_editPayType">[修改]</a>{/if}</div>
              {*
              <div class="lin-box">
                <div class="pay-type">支付方式：{openapi_config::$pay_type[$order_info.pay_type]['title']}支付</div>
                <span>配送方式：</span>
                <span class="js_expressTitle">{$order_info.express_title}</span>
                <span>中小件商品</span>　
                {if $order_info.progress > 0 && $order_info.progress < 15}
                <a href="javascript:void(0);">预计</a>　
                <a href="javascript:void(0);">{$sentTime}</a>
                <a href="javascript:void(0);">送达</a>
                {/if}
              </div>
              *}
              <ul class="lin-box">
                <li><span>支付方式 :</span><span class="pay-type">{openapi_config::$pay_type[$order_info.pay_type]['title']}支付</span></li>
                {*
                <li>
                  <span>配送方式 :</span><span class="js_expressTitle">{$order_info.express_title}</span>
                  <span>
                    {if $order_info.progress > 0 && $order_info.progress < 20}
                    <a href="javascript:void(0);">预计{$sentTime}送达</a>
                    {/if}
                  </span>
                </li>
                *}
              </ul>
            </div>

            <div class="pay-box hidden">
              <h3 class="tit">支付方式 </h3>
              <ul class="js_payTypeSlt" style="height: auto;padding-bottom: 10px">
                {$pay_type_list = openapi_config::$pay_type}
                {foreach $pay_type_list as $k=>$v}
                <li style="padding:8px;margin:0px;" {if $k == $order_info.pay_type}class="pay-curr"{/if} data-pay_type="{$k}" data-title="{$v.title}"><em class="ico"></em>{$v.title}支付<span>{$v.msg}</span></li>
                {/foreach}
              </ul>
              {*
              <h3 class="tit">配送方式 </h3>
              <ul class="js_expressSlt" style="height: auto; padding-bottom: 20px">
                {foreach $express_list as $k=>$v}
                <li style="padding:8px;margin:0px;" {if $v.id == $order_info.express_id}class="pay-curr"{/if} data-express_id="{$v.id}" data-express_title="{$v.title}"><em class="ico"></em>{$v.title}支付<span>{if $v.price_info.info == 'ok'}快递：{$v.price_info.price}元{else}{$v.price_info.info}{/if}</span></li>
                {/foreach}
              </ul>*}
              <div class="save"><a class="js_savePayType" href="javascript:void(0);" data-express_id="{$order_info.express_id}" data-express_error="" data-order_id="{$order_info.id}" data-pay_type="{$order_info.pay_type}" data-title="{openapi_config::$pay_type[$order_info.pay_type]['title']}">保存</a></div>
            </div>
            <!--支付方式   end-->
          </div>
          <div class="peninfo js_addressForm hidden" data-order_id="{$order_info.id}">
            <ul class="js_addressList" style="height: auto;">
              {foreach $address_list as $k=>$v}
              <li style="padding:8px;margin:0px;" data-address_id="{$v.id}" class="js_addressEdit {if $address_info.id == $v.id}pen-curr{/if}"><em class="ico"></em>{$v.province} {$v.city} {$v.district} {$v.address} ({$v.receiver} 收) {$v.mobile}<span data-type="child" data-address_id="{$v.id}">编辑</span></li>
              {/foreach}
              <li style="padding:8px;margin:0px;" data-address_id="new" class="js_addressAdd {if !$address_info.id}pen-curr{/if}"><em class="ico"></em>使用新地址</li>
              <input type="hidden" class="js_sltAddressInp" value="{if $address_info.id}{$address_info.id}{else}new{/if}"/>
            </ul>
            <div class="add-info js_addressFormDiv {if $address_info.id}hidden{/if}">
              <label class="infos"><span>收 货 人 ： </span><input type="text" value="{$address_info.receiver}" class="js_ADDReceiver"/></label>
              <label class="" id="addressSlt"><span>收货地区：</span>
                <div class="info-select">
                  <select name="select1" id="prov"></select>
                </div>
                <div class="info-select">
                  <select name="select2" id="city"></select>
                </div>
                <div class="info-select">
                  <select name="select3" id="dist"></select>
                </div>
              </label>
              <input type="hidden" id="pre_province" value="{$address_info.province_id}"/>
              <input type="hidden" id="pre_city" value="{$address_info.city_id}"/>
              <input type="hidden" id="pre_district" value="{$address_info.district_id}"/>
              <label class="infos2"><span>详细地址：</span><input type="text" value="{$address_info.address}" class="js_ADDAddress"/></label>
              <label class="infos"><span>手　　机：</span><input type="text" value="{$address_info.mobile}" class="js_ADDMobile"/>　<span>或　固定电话：</span><input type="text" value="{$address_info.tel}" class="js_ADDTel"/></label>
              <div class="skin skin-check js_ADDIsDefault"><span><em></em><input type="checkbox"/></span>设为默认地址</div>
            </div>

            <div class="save tb"><a href="javascript:void(0);" class="js_ADDSave">保存</a></div>
          </div>
          <!--收货人信息   end-->
        </div>
        <!--address end-->
      </div>
      <!--details end-->

    </div>
    <!--con-top  end-->

  </div>
  <!--inner  end-->
</div>

{if $order_info.pay_type == 2 && $is_direct_pay ==1}
<div class="float-er-code hidden">
  <div class="top"><h2>微信扫码支付</h2><a href="javascript:void(0);" class="close"></a></div>
  <div class="img-box"><img src="" id="qrcode_imgbox" width="280" height="280"></div>
  <p class="text">请使用微信手机客户端扫描上方二维码进行支付</p>
</div>
<script type="text/javascript">
  var order_id = {$order_info.id};
  $(function(){
    $('.float-er-code .close').click(function(){
      $('.black-shade').trigger('click');
      clearInterval(order_is_pay_success);
    });

  if(!order_id) {
    showMsg('支付失败，请重新支付');
  }

  var url     = siteUrl + '/openapi/weixin/pay/index';
  var data    = { 'order_id':order_id };
  // ajax 生成订单,以及支付所需参数
  $.post(url, data, function(json){
    if (json.info != 'ok') {
      // thisBtn.attr('is-post', 0);
      showMsg(json.info);
      return false;
    } else {
      $('#qrcode_imgbox').attr('src', json.img_url);
      $('.black-shade').show();
      $('.float-er-code').show();
    }
  },'json');

  //轮询查询是否付款
  var order_is_pay_success = setInterval(function(){
      $.post(siteUrl + '/order/query_order', { 'order_id':order_id }, function(json){
        if(json.info == 'ok') {
          location.href = siteUrl + "/order/"+order_id+".html";
        }
      },'json');
  }, 3000);

  });
</script>
{/if}
{load_js file="address/AjaxAddress.js"}
{load_js file="app/address.js?time={time()}"}
{load_js file="app/center_order.js?time={time()}"}
{include_core file="lib/footer.html"}